/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.fspike.contentprovider.localprovider;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import org.springframework.core.io.ClassPathResource;

/**
 *
 * @author Kenneth
 */
public class ResourceContentProvider {

    public static URL getDefaultImageURL() throws IOException {
        return new ClassPathResource("compomics.png").getURL();
    }

    /**
     * Returns the tips of the day.
     *
     * @return the tips of the day in an ArrayList
     */
    public static ArrayList<String> getTips() {

        ArrayList<String> tips;

        try {
            InputStream stream = new ResourceContentProvider().getClass().getResource("/tips.txt").openStream();
            InputStreamReader streamReader = new InputStreamReader(stream);
            try (BufferedReader b = new BufferedReader(streamReader)) {
                tips = new ArrayList<>();
                String line;
                
                while ((line = b.readLine()) != null) {
                    tips.add(line);
                }
            }
        } catch (IOException e) {
            tips = new ArrayList<>();
        }

        return tips;
    }

}
